/*
 * jquery.errorSummary File
 *
 * @link http://riedel-st.de
 * @author Stefan Riedel <sr@riedel-st.de>
 */
;(function($) {
    $.extend($.fn, {
        errorSummary: function(options, errorObject) {
            var defaults = {
                divClass: 'ui-state-highlight ui-corner-all errorSummary',
                header: '<p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>Es sind Fehler aufgetreten, diese müssen zuerst behoben werden:</p>\n'
            };
            var options = $.extend(defaults, options);

            return this.each(function(){
                var container = $(this);
                var errorSummaryContainer = '';
                var errorList = '';                
                $.each(errorObject, function(summary, errorMessage){
                    errorList += '<li id="' + summary + '_error">' + errorMessage + '</li>\n';
                });
                errorSummaryContainer += '<div class="' + options.divClass + '">' + options.header + errorList + '</div>\n';
                container.html(errorSummaryContainer);
            });
        }
    });
})(jQuery);